package cn.itcast

import org.apache.spark.sql.SparkSession

object HiveSupport {
  //操作HiveSQL
  def main(args: Array[String]): Unit = {
    //1、创建sparkSession
    val spark: SparkSession = SparkSession.builder()
      .appName("HiveSupport")
      .master("spark://ha01:7077")
      .enableHiveSupport() //开启支持hive
      .getOrCreate()
    spark.sparkContext.setLogLevel("WARN")  //设置日志输出级别
    //2.操作sql语句

    spark.sql("create database ideaspark")
    spark.sql("show databases").show()
    //spark.sql("CREATE TABLE IF NOT EXISTS student (id int, name string, age int) row format delimited fields terminated by ','")
    //spark.sql("LOAD DATA LOCAL INPATH './data/student.txt' INTO TABLE student")
    //spark.sql("select * from student").show()
    spark.stop()
  }
}
